package com.free;

import com.free.annotation.Scan;
import com.free.ioc.SimpleIOC;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author kanlei
 * @email freefree.me@qq.com
 * @since 2020-11-03
 */
@Slf4j
@Scan(scan = "com.free")
public class CMain {

    static {
        String scan = CMain.class.getDeclaredAnnotation(Scan.class).scan();
        try {
            ioc = new SimpleIOC(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static SimpleIOC ioc;

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++) {

            new Thread(() -> {
                Hello hello = (Hello) ioc.getBean("Hello");
                log.info(hello.hello("Hello"));
            },"Thread_" + i).start();

        }
        TimeUnit.SECONDS.sleep(Integer.MAX_VALUE);
    }
}
